package com.sicheng.蓝桥.练习题.dp;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/3/26 19:06
 */
public class 包子凑数_黄旭祥 {
    /**
     * 这代码读的有点劫后余生的感觉  (嘿嘿, 我扯犊子的)
     *
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zhonglei = sc.nextInt();
        int[] arr = new int[zhonglei];
        for (int i = 0; i < zhonglei; i++) {
            arr[i]=sc.nextInt();
        }
        int min = Arrays.stream(arr).min().getAsInt();
        //从0开始
        boolean[] dp = new boolean[(int)1e5];
        //初始化dp数组
        dp[0]=true;
        int count_min=0;
        int flag=0;
        int index=0;
        sign:
        for (int i = 1; i <(int)1e5; i++) {
            for (int j = 0; j <zhonglei; j++) {
                if (i>=arr[j]){
                    dp[i]=dp[i]||dp[i-arr[j]];
                    //为true的时候
                    if (dp[i]&&i>index){
                        count_min++;
                        index=i;
                        if (count_min==min){
                            flag=1;
                            break sign;
                        }
                    }else {
                        count_min=0;
                    }
                }
            }
        }
        int count=0;
        if (flag==1){
            for (boolean b : dp) {
                if (!b){
                    count++;
                }
            }
            System.out.println(count);
        }else {
            System.out.println("INF");
        }



    }
}
